<template>
	<view class="content"  v-if="showPop">
		<view class="advertising">
			<image :src="$imgUrls(pageData.start_img) " mode="aspectFill"></image>
		</view>
		<view class="fiexd_bottom flexac black size26" @click="closePop">
			<text class="m-right4">跳过</text>
			<text>{{cudTime}}</text>
			<text class="m-left4">S</text>
		</view>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex';
	export default {
		name:'startPage',
		data() {
			return {
				pageData:'',
				cudTime:3,
				dtime:null,
				showPop:false,
				appId:'wx2155c441e8941440',
			}
		},
		created() {
			//  #ifdef MP-WEIXIN
			const info = uni.getAccountInfoSync();
			if(info) this.appId = info.miniProgram.appId;
			// #endif
			this.startUp();
		},
		mounted() {
			this.changeTab({tabId:1})
		},
		methods: {
			...mapMutations(['getUser','changeTab']),
			startUp(){
				this.$http.post({
					url:'/zzj_singleSaleApi/startUp',
					data:{
						appid:this.appId
					}
				}).then(res=>{
					if(res.errcode != 100) return this.$Toast(res.msg);
					const result = res.data;
					this.pageData = result;
					this.cudTime = result.countdown;
					const obj = {
						bid:res.bid,
						tabBar:res.diy_table_bar.compCont,
						logo:result.logo_img,
						share:result.share,
						nameDefinition:result.nameDefinition,
						withdrawal_rules:result.withdrawal_rules,
						mode:result.mode,
						startUp:result,
						color:res.themeConfig.colorVal1
					}
					this.getUser(obj);
					this.$emit('diyget');
					
					uni.setStorageSync('bid', res.bid);
					uni.setStorageSync('shareData', result.share)
					uni.setStorageSync('mode', result.mode ? result.mode : '0');
					uni.setStorageSync('startUp', result);
					getApp().globalData.color = res.themeConfig.colorVal1
					getApp().globalData.color_aid = res.themeConfig.colorVal2
					
					
					if(result.startUp != 1) return;
					this.showPop = true;
					this.dtime = setInterval(()=>{
						if(this.cudTime > 1){
							this.cudTime --;
						}else{
							this.closePop();
						}
					},1000)
				})
			},
			closePop(){
				clearInterval(this.dtime);
				this.showPop = false;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		width:100%;
		height: 100vh;
		position: fixed;
		top:0;
		left:0;
		z-index:88888;
		background: #FFFFFF;
	}
	.advertising {
		width: 100%;
		height: 100%;
		position: absolute;
		image {
			width: 100%;
			height: 100%;
		}
	}
	
	.fiexd_bottom{
		width: 160rpx;
		height: 70rpx;
		border-radius: 35rpx;
		position: absolute;
		bottom: 100rpx;
		right: 20rpx;
		background: #FFFFFF;
	}
</style>
